<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>vue组件--插槽</title>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1">

</head>

<body>

    <div id="app">
        <my-list :list-data="data">
                <template slot="cont" slot-scope="{ item }">
                    <span>name:{{item.name}}</span> <span>age:{{item.age}}</span>
                </template>
        </my-list>
    </div>
    <script src="../js/vue.min.js"></script>
    <script>
        Vue.component('my-list', {
            props: ['listData'],
            template: `
            <div>
                <div v-for="(item,index) in listData" :key="index">
                        <slot name="cont"  v-bind:item="item"></slot>
                </div>
            </div>
            `
        })

        var app = new Vue({
            el: "#app",
            data: {
                data: [{
                    name: 'wjx', age: 20
                }, {
                    name: 'wjx', age: 20
                }, {
                    name: 'wjx', age: 20
                }]
            }
        })

    </script>
</body>
